$(function () {
    obj.init();
});

var obj = new function () {
    "use strict";
    return {
        form : null,
        dom  : {
            saveBtn  : null,
            closeBtn : null,
            checkStr : null
        },
        params : {
            iTTchId : null,
            iState  : null,
            mCheck  : null
        },
        init  : function () {
            this.dom.saveBtn    = window.top.xhTop.getModalConfirmDom();
            this.params.iTTchId = xhTool.getQuery('iTTchId');
            this.dom.closeBtn   = $(window.top.xhTop.getModalCloseDom()[1]);
            this.dom.checkStr   = $('[name = mCheck]');
            this.form           = new xhForm($('#xh_form')).parse().fill(trackInfo);
            this.dom.closeBtn.text('退回');
            this.listener();
        },
        listener : function () {
            var $this = this;
            $this.dom.saveBtn.click(function () {
               $this.funObj().saveCheck();
            });
            $this.dom.closeBtn.click(function () {
                $this.funObj().backCheck();
            })
        },
        funObj : function () {
            var $this = this;
            return {
                saveCheck : function () {
                    $this.params.mCheck = $this.dom.checkStr.val();
                    $this.params.iState = 2;  //审核通过
                    $.ajax({
                        url  : baseUrl+'tch/saveTrackCheck',
                        data : $this.params,
                        type : 'post',
                        dataType : 'json',
                        success : function (data) {
                            window.top.swal('' , data['msg'] , 'success');
                        },
                        error : function (result) {
                            window.top.swal('' , result['responseText'] , 'error');
                        },
                        complete:function () {
                            window.top.xhTop.getActiveFrame()['track'].location.reload();
                            window.top.xhTop.closeModal();
                        }
                    });
                },
                backCheck : function () {
                    $this.params.mCheck = $this.dom.checkStr.val();
                    $this.params.iState = 3;  //退回
                    $.ajax({
                        url  : baseUrl+'tch/saveTrackCheck',
                        data : $this.params,
                        type : 'post',
                        dataType : 'json',
                        success : function (data) {
                            window.top.swal('' , data['msg'] , 'success');
                        },
                        error : function (result) {
                            window.top.swal('' , result['responseText'] , 'error');
                        },
                        complete:function () {
                            window.top.xhTop.getActiveFrame()['track'].location.reload();
                            window.top.xhTop.closeModal();
                        }
                    });
                },
            }
        },
           
       
    }

}